package com.demo.passenger.sys.role.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.passenger.sys.role.entity.SysRolePermission;
import com.demo.passenger.sys.role.service.ISysRolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author weifucheng
 * @since 2019-07-13
 */
@Controller
@RequestMapping("/sys/role/permission")
public class SysRolePermissionController {
    @Autowired
    ISysRolePermissionService sysRolePermissionService;

    @RequestMapping("/listByParams")
    @ResponseBody
    public List<SysRolePermission> listByParams(Page<SysRolePermission> page, SysRolePermission sysRolePermission){
        return sysRolePermissionService.listByParams(page,sysRolePermission);
    }

    @RequestMapping("/listAll")
    @ResponseBody
    public List<SysRolePermission> listAll(){
        return sysRolePermissionService.list();
    }

    @RequestMapping("/save")
    @ResponseBody
    public Boolean save(SysRolePermission sysRolePermission){
        return sysRolePermissionService.saveOrUpdate(sysRolePermission);
    }

    @RequestMapping("/update")
    @ResponseBody
    public Boolean update(SysRolePermission sysRolePermission){
        return sysRolePermissionService.saveOrUpdate(sysRolePermission);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Boolean delete(SysRolePermission sysRolePermission){
        return sysRolePermissionService.removeById(sysRolePermission.getId());
    }
}
